package com.zhixiang.xaec.action.system;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zhixiang.core.web.action.BaseAction;
import com.zhixiang.xaec.entity.system.CompanyInfo;
import com.zhixiang.xaec.service.system.CompanyInfoService;

@Controller
@Scope("prototype")
public class CompanyInfoAction extends BaseAction
{
    private static final long serialVersionUID = 1790343147457381317L;
    
    private CompanyInfo companyInfo;
    
    @Resource(type=CompanyInfoService.class)
    CompanyInfoService companyInfoService;
    
    public CompanyInfo getCompanyInfo()
    {
        return companyInfo;
    }

    public void setCompanyInfo(CompanyInfo companyInfo)
    {
        this.companyInfo = companyInfo;
    }

    public String get(){        
        if(companyInfoService.get(Long.valueOf(1))==null){
            CompanyInfo cif=new CompanyInfo();
            cif.setId(1L);
            companyInfoService.save(cif);
            setResult(cif); 
        }else{
            setResult(companyInfoService.get(Long.valueOf(1))); 
        }
              
        return SUCCESS;
    }
    
    public String save(){      
        companyInfoService.save(companyInfo);
        return SUCCESS;
    }

}
